package org.example.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * ThreadLocal 工具类
 */
@SuppressWarnings("all")
public class ThreadLocalUtil {
    private static final ThreadLocal<Map<String, Object>> THREAD_LOCAL = new ThreadLocal<>();

    public static void set(Map<String, Object> map) {
        THREAD_LOCAL.set(map); //存储
    }

    public static Map<String, Object> get() {
        return THREAD_LOCAL.get(); //获取
    }

    //清除ThreadLocal，防止内存泄露
    public static void remove() {
        THREAD_LOCAL.remove();
    }
}